<?php
namespace app\index\controller;
use think\Controller;
use think\Request;
use app\index\model\Pay;
use think\Loader;
use think\Db;
use think\Session;
use think\Cookie;
include EXTEND_PATH.'alipay/AlipayPay.php';
class Pay1 extends Controller
{
  	public static $uid;
  	public static $price;
	//支付宝支付接口
	public function index()
	{	
    	$request = Request::instance();
         $a=$request->param();
      
       	$time = time();
		$out_trade_no = $this->creatOrder();
		$sql = "update user set money=money+".$a['price']." where userid = ".$a['uid'];
		$res = Db::query($sql);
		$alipay = new \alipay\Alipaypay();
		$alipay->requestPay($out_trade_no,'订单',0.01,$a['uid'].','.$a['price']);
	}
	public function creatOrder()
	{
		return date('Ymd') . str_pad(mt_rand(1, 99999), 5, '0', STR_PAD_LEFT);
	}
	public function paySuccess(Request $request)
	{
		$body = $request->param("body");
		$arr = explode(',',$body);
      echo "充值成功";die;
		header("location:http://47.9..21.169/old/Index/user.html");
	}
}
